package com.sumainfor.pc.epc.controller.tenant;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.epc.service.StockManageService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Jack Chen
 * @Create 2019-02-15 15:04
 * 提供暴露的远程调用接口
 */
@RestController
@RequestMapping("/tenant/key")
public class TenantProviderController {

    @Autowired
    private StockManageService stockManageService;

    /**
     * 获得商品的名称和图标 通过商品编号集合
     *
     * @param ids
     * @return
     */
    @PostMapping("/getShopNameAndIcon")
    public JsonResult getShopNameAndIcon(@RequestBody List<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return JsonResult.errorForEmpty();
        }
        return stockManageService.selectShopNameAndIcon(ids);
    }

    /**
     * 根据房源配置主编号查询房源配置详表信息
     *
     * @param configId
     * @return
     */
    @PostMapping("/selectConfigInfoByConfigId")
    public JsonResult selectConfigInfoByConfigId(String configId) {
        if (StringUtils.isBlank(configId)) {
            return JsonResult.errorForEmpty();
        }
        return stockManageService.selectConfigInfoByConfigId(configId);
    }

    /**
     * 获取商品的编号根据房源配置编号 - 公共区域用
     *
     * @param ids
     * @return
     */
    @PostMapping("/selectComIdArrayByConIdList")
    public JsonResult selectComIdArrayByConIdList(@RequestBody List<String> ids) {
        return stockManageService.selectComIdArrayByConIdList(ids);
    }

}
